package com.hyjr.RxTask;

import com.hyjr.RxTask.common.Constants;
import com.hyjr.RxTask.netty.server.ReceiveTaskServer;
import com.hyjr.RxTask.rabbitmq.ConsumerUtil;
import com.hyjr.RxTask.rabbitmq.RabbitmqConstants;
import com.hyjr.RxTask.work.CheckResultWork;
import com.hyjr.RxTask.work.ComplexCheckWork;
import com.hyjr.RxTask.work.MiddleCheckWork;
import com.hyjr.RxTask.work.SimpleCheckWork;
import com.hyjr.RxTask.work.TaskScheduleWork;
import com.hyjr.RxTask.work.service.ConsumerWork;
import com.hyjr.common.enums.CheckTypeEnum;
import com.hyjr.common.utils.LogUtils;

/**
 * Hello world!
 *
 */
public class App {
	public static void main(String[] args) {
//		String base64String="w,*$!!hu\nang-123测试";
		try {
//			System.out.println("base64String：" + base64String);
//			String encodedText = Base64.getEncoder().encodeToString(base64String.getBytes("UTF-8"));
//			System.out.println("编码：" + encodedText);
//			String decodeText = new String(Base64.getDecoder().decode(encodedText), "UTF-8");
//			System.out.println("解码：" + decodeText);

			LogUtils.debug("检测端，启动App，开始");
			
			ConsumerWork checkResultWork = CheckResultWork.GetInstance();
			ConsumerWork complexCheckWork = ComplexCheckWork.GetInstance();
			ConsumerWork middleCheckWork = MiddleCheckWork.GetInstance();
			ConsumerWork simpleCheckWork = SimpleCheckWork.GetInstance();
			ConsumerWork taskScheduleWork = TaskScheduleWork.GetInstance();

			//开启消费端
			ConsumerUtil.consumer(RabbitmqConstants.CHECK_DISTR_PRE + CheckTypeEnum.SIMPLE, simpleCheckWork);
			ConsumerUtil.consumer(RabbitmqConstants.CHECK_DISTR_PRE + CheckTypeEnum.MIDDLE, middleCheckWork);
			ConsumerUtil.consumer(RabbitmqConstants.CHECK_DISTR_PRE + CheckTypeEnum.COMPLEX, complexCheckWork);
			ConsumerUtil.consumer(RabbitmqConstants.REQ_TASK_INFO, taskScheduleWork);
			ConsumerUtil.consumer(RabbitmqConstants.CHECK_RESULT, checkResultWork);
			
			//启动netty服务端
			ReceiveTaskServer ReceiveTaskServer = new ReceiveTaskServer();
			ReceiveTaskServer.start(Constants.RECEIVE_PWD_SERVER_PORT);
			
			LogUtils.debug("检测端，启动App，结束");
		} catch (Exception e) {
			LogUtils.debug("检测端，启动异常，" + e.getMessage());
			e.printStackTrace();
		}
	}
}
